package user

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/userServiceClient/userrpc"
	"github.com/zeromicro/go-zero/core/logx"
)

type UserBatchImportLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 会员管理 - 批量批量通过文件导入用户
func NewUserBatchImportLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserBatchImportLogic {
	return &UserBatchImportLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserBatchImportLogic) UserBatchImport(req *types.UserBatchImportAddRequest) (resp *types.UserBatchImportAddResponse, err error) {
	_, err = l.svcCtx.UserServiceRPC.UserBatchImport(l.ctx, &userrpc.UserBatchImportRequest{
		FilePath:      req.FilePath,
		FileType:      req.FileType,
		FileEncoding:  req.FileEncoding,
		FileDelimiter: req.FileDelimiter,
	})
	if err != nil {
		return nil, err
	}
	return &types.UserBatchImportAddResponse{}, nil
}
